package com.tsd.system.controller;

import com.tsd.common.controller.BaseController;
import com.tsd.core.vo.ErrorCode;
import com.tsd.core.vo.HttpResult;
import com.tsd.system.service.SystemSettingService;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @ClassName: SystemSettingController
 * @Description: TODO
 * @Author: Hillpool
 * @Date: 2021/10/23 10:46
 * @Version: 1.0
 */
@Controller
@Scope("prototype")
@RequestMapping("/api/v2")
@Api(tags = "内容管理-配置", description = "配置的API描述")
public class SystemSettingController extends BaseController {

    @Resource
    private SystemSettingService systemSettingService;

    @ResponseBody
    @RequestMapping(value = "/clearSystemSettingCache.action", method = RequestMethod.POST)
    public HttpResult<Object> clearSystemSettingCache() {
        HttpResult<Object> hr = new HttpResult<>();
        try {
            systemSettingService.clearSystemSettingCache();
            hr.setCode(ErrorCode.CODE_SUCCESS);
        } catch (Exception e) {
            super.procException(hr, e);
        }
        return hr;
    }

    @ResponseBody
    @RequestMapping(value = "/clearGlobalSettingCache.action", method = RequestMethod.POST)
    public HttpResult<Object> clearGlobalSettingCache() {
        HttpResult<Object> hr = new HttpResult<>();
        try {
            systemSettingService.clearGlobalSettingCache();
            hr.setCode(ErrorCode.CODE_SUCCESS);
        } catch (Exception e) {
            super.procException(hr, e);
        }
        return hr;
    }
}
